<!-- 单位资质审核 -->
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="90px"
    >
      <el-form-item label="审核状态" prop="verifyStatus">
        <el-select
          v-model="queryParams.verifyStatus"
          placeholder="请选择审核状态"
          clearable
          @change="handleQuery"
        >
          <el-option
            v-for="dict in dict.type.verify_status"
            :key="dict.value"
            :label="dict.label"
            :value="Number(dict.value)"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column
        label="单位名称"
        prop="company.cname"
        align="center"
        fixed="left"
        min-width="200"
      ></el-table-column>
      <el-table-column
        label="单位类型"
        prop="company.comtype"
        align="center"
        width="100"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.company_type"
            :value="scope.row.company.comtype"
          />
        </template>
      </el-table-column>
      <el-table-column label="单位等级" prop="company.levels" align="center" width="100">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.company_level"
            :value="scope.row.company.levels"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="资质审核状态"
        align="center"
        width="100"
      >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.verify_status" :value="String(scope.row.verifyStatus)" />
        </template>
      </el-table-column>
      <el-table-column
        label="审核说明"
        prop="verifyRemark"
        align="center"
        width="150"
      />
      <el-table-column label="单位地址" prop="company.addressall" align="center" min-width="180" />
      <el-table-column label="单位联系人" prop="company.contactName" align="center" width="100" />
      <el-table-column label="联系人电话" prop="company.phone" align="center" width="120" />

      <el-table-column label="创建人" prop="createUser" align="center" width="100" />
      <el-table-column label="申请时间" prop="createTime" align="center" width="200" />
      <el-table-column label="审核时间" prop="verifyTime" align="center" width="200" />
      <el-table-column label="审核人" prop="verifyUser" align="center" width="100" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="120px"
        fixed="right"
      >
        <template slot-scope="scope">
            <el-button
              v-if="!scope.row.verifyStatus && hasPermiAnd(['company:certification:audit'])"
              size="mini"
              type="text"
              icon="el-icon-s-check"
              @click="handleOpen(scope.row.id)"
              >审核</el-button
            >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <AuditDialog ref="AuditDialog" @refresh="getList" />
  </div>
</template>

<script>
import { companyVerifyList } from "@/api/company/company.js";
import AuditDialog from './auditDialog.vue';
import { hasPermiAnd } from '@/plugins/auth'

export default {
  name: "Certification",
  dicts: ["company_type", "company_level", "verify_status"],
  components: {
    AuditDialog
  },
  data() {
    return {
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        verifyStatus: undefined,
      },
      dataList: [],
    };
  },
  created() {
    this.getList();
  },
  activated() {
    this.getList();
  },
  methods: {
    hasPermiAnd,
    getList() {
      this.loading = true;
      companyVerifyList(this.queryParams).then((response) => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleOpen(id) {
      this.$refs.AuditDialog.openDialog(id)
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
